package com.lzq.leetcode.hoot100;

import java.util.Arrays;

public class s322 {

    public int coinChange(int[] coins, int amount) {
        int INF = amount + 1;
        int[] dp = new int[amount + 1];

        Arrays.fill(dp, INF);

        dp[0] = 0;
        for (int i=1; i<=amount; i++) {
            for (int c : coins) {
                if (i - c >= 0) {
                    dp[i] = Math.min(dp[i], dp[i-c] + 1);
                }
            }
            System.out.println(dp[i]);
        }
        return dp[amount] == INF ? -1 : dp[amount];
    }

    public static void main(String[] args) {

        s322 s322 = new s322();
        System.out.println(s322.coinChange(new int[]{1, 2, 5}, 11));
    }
}
